<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 3.3</title>
</head>

<body>
<?php
	if(isset($_POST['nam_dl']))
	{
		$nam_dl=$_POST['nam_dl'];
		if(is_numeric($nam_dl)){
			$nam_tru=$nam_dl-3;
			$nam=$nam_tru%10;
			//Tính can
			switch($nam){
				case 1:$can="Giáp";break;
				case 2:$can="Ất";break;
				case 3:$can="Bính";break;
				case 4:$can="Đinh";break;
				case 5:$can="Mậu";break;
				case 6:$can="Kỷ";break;
				case 7:$can="Canh";break;
				case 8:$can="Tân";break;
				case 9:$can="Nhâm";break;
				case 0:$can="Quý";break;
			}
			$nam=$nam_tru%12;
			//Tính chi
			switch($nam){
				case 1:$chi="Tý";$linkhinh='ti';break;
				case 2:$chi="Sửu";$linkhinh='suu';break;
				case 3:$chi="Dần";$linkhinh='dan';break;
				case 4:$chi="Mão";$linkhinh='mao';break;
				case 5:$chi="Thìn";$linkhinh='thin';break;
				case 6:$chi="Tỵ";$linkhinh='ty';break;
				case 7:$chi="Ngọ";$linkhinh='ngo';break;
				case 8:$chi="Mùi";$linkhinh='mui';break;
				case 9:$chi="Thân";$linkhinh='than';break;
				case 10:$chi="Dậu";$linkhinh='dau';break;
				case 11:$chi="Tuất";$linkhinh='tuat';break;
				case 0:$chi="Hợi";$linkhinh='hoi';break;
			}
			$nam_al=$can.' '.$chi;
			$hinh="<img src='images/$linkhinh.gif' />";
		}
	}
?>
<form id="form1" name="form1" method="post" action="Bai3_3.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#000066" style="text-align: center; font-size: 24px; color: #FFF;">
      <td colspan="3">TÍNH NĂM ÂM LỊCH</td>
    </tr>
    <tr>
      <td bgcolor="#00CCFF">Năm dương lịch</td>
      <td bgcolor="#00CCFF">&nbsp;</td>
      <td bgcolor="#00CCFF">Năm âm lịch</td>
    </tr>
    <tr>
      <td bgcolor="#00CCFF"><input name="nam_dl" type="text" id="nam_dl" value="<?php echo $_POST['nam_dl'];?>" /></td>
      <td bgcolor="#00CCFF"><input style="background-color:#FFC; color:#F00; font-weight:bold" type="submit" name="submit" id="submit" value="=&gt;" /></td>
      <td bgcolor="#00CCFF"><input name="nam_al" type="text" id="nam_al" style="background-color:#FFC; color:#F00; font-weight:bold" value="<?php echo $nam_al;?>" /></td>
    </tr>
    <tr>
      <td colspan="3" bgcolor="#00CCFF" style="text-align: center"><?php echo $hinh;?>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>